package mysql

import "gorm.io/gorm"

type UserInfo struct {
	gorm.Model
	PhoneNum      string `gorm:"type:varchar(20);not null;comment:手机号"`
	Pwd           string `gorm:"type:varchar(32);not null;comment:密码"`
	NickName      string `gorm:"type:varchar(200);not null;comment:昵称"`
	Url           string `gorm:"type:varchar(500);not null;comment:头像"`
	AccountStatus int    `gorm:"type:int(11);not null;comment:账号状态"`
	FollowNum     int    `gorm:"type:int;not null;comment:关注数"`
	FansNum       int    `gorm:"type:int;not null;comment:粉丝数"`
}

func (i *UserInfo) FindUserByPhone(db *gorm.DB, num string) error {
	return db.Debug().Where("phone_num=?", num).First(i).Error
}

func (i *UserInfo) CreateUsers(db *gorm.DB) error {
	return db.Debug().Create(i).Error
}

func (i *UserInfo) UpdatePassword(db *gorm.DB) error {
	return db.Debug().Updates(i).Error
}

func (i *UserInfo) FindUserById(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).First(i).Error
}
